package com.itheima.service.Impl;

import com.itheima.domain.Account;
import com.itheima.domain.Trip;
import com.itheima.domain.User;
import com.itheima.mapper.AccountMapper;
import com.itheima.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("accountService")
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountMapper accountMapper;

    @Override
    public void save(Account account) { accountMapper.save(account); }

    @Override
    public void update(Account account) {
        accountMapper.update(account);
    }

    @Override
    public void delete(Integer id) {
        accountMapper.delete(id);
    }

    @Override
    public Account findById(Integer id) {
        Account account = accountMapper.findById(id);
        return account;
    }

    @Override
    public List<Account> findAll() {
        List<Account> list = accountMapper.findAll();
        return list;
    }


    /*
           编程题目三
        */
    //1. 查询旧表中所需数据
    @Override
    public List<Trip> QuaryAll() {
        return accountMapper.QueryAll();
    }

    //2. 向新表所需插入数据
    @Override
    public void insertDataToNewTable(List<Trip> tripNews) {
        accountMapper.insertDataToNewTable(tripNews);
    }

    //3. 关联查询所有信息
    @Override
    public List<User> newQueryAll() {
        return accountMapper.newQueryAll();
    }

}
